package com.tencreat.mall.controller.app;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tencreat.common.core.HttpResult;
import com.tencreat.common.core.controller.BaseController;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.domain.mall.vo.ResGoodsCollageDetailVO;
import com.tencreat.domain.mall.vo.ResGoodsCollageListAppVO;
import com.tencreat.domain.mall.dto.GoodsCollageListAppDTO;
import com.tencreat.service.mall.IMallGoodsCollageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品拼团Controller
 *
 * @author wangkai
 * @date 2021-11-16
 */
@Api(tags={"4-商品拼团"})
//@RestController
@RequestMapping("/api/collage")
public class MallGoodsCollageController extends BaseController {
    //@Autowired
    private IMallGoodsCollageService mallGoodsCollageService;


    /**
     * 查询商品拼团列表
     */
    @ApiOperation(value = "查询商品拼团列表")
    @PostMapping("/list")
    public HttpResult<IPage<ResGoodsCollageListAppVO>> list(@RequestBody GoodsCollageListAppDTO vo) {
        Page<ResGoodsCollageListAppVO> page = new Page<>(vo.getPageNum(), vo.getPageSize());
        return HttpResult.ok(mallGoodsCollageService.appPage(page, vo));
    }


    /**
     * 获取商品拼团详细信息
     */
    @ApiOperation(value = "获取商品拼团详细信息")
    @PostMapping(value = "/getInfo")
    public HttpResult<ResGoodsCollageDetailVO> getInfo(@RequestBody ReqIdParam id) {
        return mallGoodsCollageService.getGoodsCollageById(id,getLoginCheck());
    }

    /**
     * 查看本人拼团商品信息  0 历史拼团  2 正在拼团
     */
    @ApiOperation(value = "获取正在拼团商品信息")
    @PostMapping(value = "/getMyCollage")
    public HttpResult<List<ResGoodsCollageListAppVO>> getMyCollage(@RequestBody ReqIdParam id) {
        return HttpResult.ok(mallGoodsCollageService.getMyCollage(getLoginCheck(),id.getId()));
    }


}
